package com.hqyj.controller;


import com.hqyj.pojo.Department;
import com.hqyj.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/department")
public class DeparmentController {
     @Autowired
     private DepartmentService departmentService;
     @RequestMapping("selectAll")
     @ResponseBody
    public Map<String,Object> selectAll(int pageNum,int pageSize,String departmentName){
        return departmentService.selectAll(pageNum,pageSize,departmentName);
    }
    //添加用户
    @RequestMapping("addDepartment")
    @ResponseBody
    public Map<String,Object> addDeparment(Department department){
       return departmentService.inserDepartment(department);
    }
        //添加用户
//    @RequestMapping("addDepartment")
//    @ResponseBody
//    public String addDeparment(Department department){
//       return departmentService.insertDepartment(department);
//    }
    //删除用户
     @RequestMapping("deleteDepartment")
     @ResponseBody
    public Map<String,Object> deleteDepartment(String departmentName){
         return departmentService.deleteDepartment(departmentName);
    }
    //修改用户
    @RequestMapping("updateDepartment")
    @ResponseBody
    Map<String,Object> updateDepartment(Department department){
         return departmentService.updateDepartment(department);
    }

    //获取所有部门
    @RequestMapping("/getAll")
    @ResponseBody
    public Map<String,Object> getAll(){
         return departmentService.getAll();
    }

}
